﻿using System;

namespace Genko.Model
{
    public abstract class SchemaMember : Member
    {
        protected string name = null;

        protected internal SchemaMember()
        {

        }

        protected internal SchemaMember(SchemaMember owner)
            : base(owner)
        {

        }

        /// <summary>
        /// Gets the MetaModel to which this SchemaMember belongs.
        /// </summary>
        public virtual MetaModel MetaModel
        {
            get
            {
                if (this is MetaModel)
                {
                    return (MetaModel)this;
                }
                return ((SchemaMember)this.Owner).MetaModel;
            }
        }

        [MemberAttribute]
        public virtual string Name
        {
            get
            {
                return name;
            }
            protected internal set
            {
                name = value;
            }
        }

        public override bool CanBeAttached(Member member)
        {
            return (member is SchemaMember);
        }
    }
}
